package com.mvc.moduel1.reflect;

import java.lang.reflect.Constructor;

public class Person {
	private String name;
	private int age;

	public Person(){
	}
	public Person(int age){
		this.age = age;
	}
	public Person(String name){
		this.name = name;
	}
	public Person(String name,int age){
		this.name = name;
		this.age = age;
	}
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getAge() {
		return age;
	}

	public void setAge(int age) {
		this.age = age;
	}

	@Override
	public String toString() {
		return "Person [name=" + name + ", age=" + age + "]";
	}

	
}
class Hello1{
	public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
		Class<?> demo = null;
		demo = Class.forName("com.mvc.moduel1.reflect.Person");
		Person person = (Person) demo.newInstance();
		person.setAge(22);
		person.setName("daishenglei");
		System.out.println(person);
	}

}
class Hello2{
	public static void main(String[] args) {
		/*Class<?> demo = null;
		try {
			demo = Class.forName("com.mvc.moduel1.reflect.Person");
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
		Person p1 = null;
		Person p2 = null;
		Person p3 = null;
		Person p4 = null;
		Constructor<?>[] cons = demo.getConstructors();
		try {
			p1 = (Person) cons[0].newInstance();
			p2 = (Person) cons[1].newInstance(25);
			p3 = (Person) cons[2].newInstance("daishenglei");
			p4 = (Person) cons[3].newInstance("daishenglei",24);
		} catch (Exception e) {
			e.printStackTrace();
		}
		System.out.println(p1);
		System.out.println(p2);
		System.out.println(p3);
		System.out.println(p4);*/
	}
}
